﻿//****************************************************************************************************
//Author:          Jun Wang
//Guid:		       65bf49d1-b9fe-4103-b531-4552a01d127e
//DateTime:        3/4/2013 12:56:49 PM
//Email Address:   admin@9un.org
//FileName:        LibVlcMediaListInterop
//CLR Version:     4.0.30319.18033
//Machine Name:    META-DESKTOP
//Namespace:       RuanRang.Media.Core.Internal.Interop
//Function:                
//Description:    
//****************************************************************************************************
using System;
using System.Runtime.InteropServices;
using System.Security;
using log4net;

namespace RuanRang.Media.Core.Internal.Interop
{
    internal class LibVlcMediaListInterop :BaseInterop
    {
        /// <summary>
        /// Initializes the <see cref="LibVlcMediaListInterop" /> class.
        /// </summary>
        static LibVlcMediaListInterop()
        {
            Logger = LogManager.GetLogger(typeof(LibVlcMediaListInterop));
        }

        /// <summary>
        /// Create an empty media list.
        /// </summary>
        /// <param name="vlcInstance">The libvlc instance.</param>
        /// <returns>Empty media list instance, or NULL on error.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_new", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr libvlc_media_list_new(IntPtr vlcInstance);

        /// <summary>
        /// Release media list created with NewInstance().
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_release", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void libvlc_media_list_release(IntPtr mediaListInstance);

        /// <summary>
        /// Retain reference to a media list.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_retain", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void libvlc_media_list_retain(IntPtr mediaListInstance);

        /// <summary>
        /// Associate media instance with this media list instance.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="mediaInstance">The media instance.</param>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_set_media", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void libvlc_media_list_set_media(IntPtr mediaListInstance, IntPtr mediaInstance);

        /// <summary>
        /// Get media instance from this media list instance.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <returns>The media instance.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_media", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr libvlc_media_list_media(IntPtr mediaListInstance);

        /// <summary>
        /// Add media instance to media list.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="mediaInstance">The media instance.</param>
        /// <returns>0 on success, -1 if the media list is read-only.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_add_media", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_add_media(IntPtr mediaListInstance, IntPtr mediaInstance);

        /// <summary>
        ///  Insert media instance in media list on a position.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="mediaInstance">The media instance.</param>
        /// <param name="index">Position in array where to insert.</param>
        /// <returns>0 on success, -1 if the media list si read-only.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_insert_media", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_insert_media(IntPtr mediaListInstance, IntPtr mediaInstance, int index);

        /// <summary>
        /// Remove media instance from media list on a position.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="index">Position in array where to remove.</param>
        /// <returns>0 on success, -1 if the list is read-only or the item was not found.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_remove_index", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_remove_index(IntPtr mediaListInstance, int index);

        /// <summary>
        /// Get count on media list items.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <returns>Number of items in media list.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_count", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_count(IntPtr mediaListInstance);

        /// <summary>
        /// List media instance in media list at a position.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="index">Position in array where to get.</param>
        /// <returns>Media instance at position.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_item_at_index", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr libvlc_media_list_item_at_index(IntPtr mediaListInstance, int index);

        /// <summary>
        /// Find index position of List media instance in media list.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <param name="mediaInstance">The media instance.</param>
        /// <returns>Position of media instance.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_index_of_item", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_index_of_item(IntPtr mediaListInstance, IntPtr mediaInstance);

        /// <summary>
        /// This indicates if this media list is read-only from a user point of view.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <returns>0 on readonly, 1 on readwrite.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_is_readonly", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern int libvlc_media_list_is_readonly(IntPtr mediaListInstance);

        /// <summary>
        /// Get lock on media list items.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_lock", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void libvlc_media_list_lock(IntPtr mediaListInstance);

        /// <summary>
        /// Release lock on media list items.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_unlock", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern void libvlc_media_list_unlock(IntPtr mediaListInstance);

        /// <summary>
        /// Get libvlc_event_manager from this media list instance.
        /// </summary>
        /// <param name="mediaListInstance">The media list instance.</param>
        /// <returns>The event manager associated with mediaListInstance.</returns>
        [DllImport("libvlc", ExactSpelling = true, EntryPoint = "libvlc_media_list_event_manager", CallingConvention = CallingConvention.Cdecl)]
        [SuppressUnmanagedCodeSecurity]
        public static extern IntPtr libvlc_media_list_event_manager(IntPtr mediaListInstance);
    }
}
